home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form DynamicRecordSet
- Caption = "DynamicRecordSet"
- ClientHeight = 7116
- ClientLeft = 876
- ClientTop = 1524
- ClientWidth = 5796
- BeginProperty Font
- name = "Arial"
- charset = 0
- weight = 700
- size = 7.8
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 7440
- Left = 828
- LinkTopic = "Form1"
- ScaleHeight = 7116
- ScaleWidth = 5796
- Top = 1248
- Width = 5892
- Begin VB.CommandButton btnRecSetNamePrevious
- Caption = "
- BeginProperty Font
- name = "Wingdings"
- charset = 2
- weight = 700
- size = 18
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 540
- Left = 1548
- TabIndex = 4
- Top = 6468
- Width = 925
- End
- Begin VB.CommandButton btnRecSetNameLast
- Caption = "
- BeginProperty Font
- name = "Wingdings"
- charset = 2
- weight = 700
- size = 18
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 540
- Left = 4056
- TabIndex = 3
- Top = 6468
- Width = 925
- End
- Begin VB.CommandButton btnRecSetNameNext
- Caption = "
- BeginProperty Font
- name = "Wingdings"
- charset = 2
- weight = 700
- size = 18
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 540
- Left = 2928
- TabIndex = 2
- Top = 6468
- Width = 925
- End
- Begin VB.CommandButton btnRecSetNameFirst
- Caption = "
- BeginProperty Font
- name = "Wingdings"
- charset = 2
- weight = 700
- size = 18
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 540
- Left = 480
- TabIndex = 1
- Top = 6468
- Width = 925
- End
- Begin VB.TextBox txtName
- BeginProperty Font
- name = "Arial"
- charset = 0
- weight = 400
- size = 7.8
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 300
- Index = 0
- Left = 2232
- TabIndex = 0
- Text = "txtName"
- Top = 408
- Width = 3396
- End
- Begin VB.Label lblName
- Alignment = 1 'Right Justify
- Caption = "lblName"
- Height = 312
- Index = 0
- Left = 84
- TabIndex = 5
- Top = 408
- Width = 2028
- End
- Attribute VB_Name = "DynamicRecordSet"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Public dbDatabase As Database
- Public rsRecSetName As Recordset
- Public Sub A_ReadMe()
- 'This template is designed for use with the RAD-Copy Buddy.
- 'Purpose: This template provides Recordset navigation
- ' buttons along with all supporting procedures.
- 'Usage: 1) Change {{RecSetName}} to desired RecordSet
- ' variable name
- ' 2) RAD-Copy all 4 Command Buttons and txtName
- ' to desired form.
- ' 3) RAD-Copy Declarations, {{RecSetName}}ButtonStatus,
- ' and {{RecSetName}}Populate to desired form.
- ' 4) On the target form, Copy/Paste txtName to create a
- ' ControlArray with as many Textboxes as there will be
- ' columns returned by your recordset.
- ' 5) Or, RAD-Copy and call {{RecSetName}}CreateControls
- ' to dynamically create Labels and Textboxes for
- ' Recordset fields at run time.
- ' 6) You can modify {{RecSetName}}Populate as indicated to
- ' bypass text box display or perform custom DB processing.
- ' 7) Code the target form to initialize rs{{RecSetName}}
- ' and dbDatabase (See Sample_Form_Load).
- 'Comments: These templates support fields that can be displayed
- ' as text only. Template does not include routines
- ' for database updates.
- 'Tags:
- '{{RecSetName}}
- End Sub
- Public Sub RecSetNameCreateControls()
- '** Dynamically create controls and labels from the
- '** rsRecSetName to display fields.
- Dim nColCount As Integer
- Dim nTop As Integer
- '** Verify #of columns and initialize primary Controls
- If rsRecSetName.Fields.Count > 0 Then
- txtName(0).Text = ""
- lblName(0).Caption = rsRecSetName.Fields(0).Name
- nTop = txtName(0).Top
- End If
- '** Loop thru remaining Fields and initialize controls
- For nColCount = 1 To rsRecSetName.Fields.Count - 1
- Load txtName(nColCount)
- Load lblName(nColCount)
- '** Calculate top independent of scale
- nTop = nTop + txtName(nColCount).Height * 1.2
- txtName(nColCount).Text = ""
- txtName(nColCount).Top = nTop
- lblName(nColCount).Caption = rsRecSetName.Fields(nColCount).Name
- lblName(nColCount).Top = nTop
- txtName(nColCount).Visible = True
- lblName(nColCount).Visible = True
- Next nColCount
- Exit Sub
- End Sub
- Private Sub RecSetNameButtonStatus()
- '** Set Visible based on record position
- If rsRecSetName.AbsolutePosition = 1 Then
- btnRecSetNamePrevious.Visible = False
- Else
- btnRecSetNamePrevious.Visible = True
- End If
- If rsRecSetName.EOF Then
- btnRecSetNameNext.Visible = False
- Else
- btnRecSetNameNext.Visible = True
- End If
- End Sub
- Public Sub RecSetNamePopulate()
- Dim nColCount As Integer
- Dim vReturnRows As Variant
- Dim vReturnValue As Variant
- '** Return array of current row's field values
- vReturnRows = rsRecSetName.GetRows(1)
- '** Populate TextBoxes. If you do not want to use the
- '** standard text boxes, insert your processing of the
- '** vReturnRows array of returned fields here:
- For nColCount = 0 To rsRecSetName.Fields.Count - 1
- vReturnValue = vReturnRows(nColCount, 0)
- If Not IsNull(vReturnValue) Then
- txtName(nColCount).Text = CStr(vReturnValue)
- Else
- txtName(nColCount).Text = ""
- End If
- Next nColCount
- Exit Sub
- End Sub
- Private Sub btnRecSetNameLast_Click()
- rsRecSetName.MoveLast
- RecSetNamePopulate
- RecSetNameButtonStatus
- Exit Sub
- End Sub
- Private Sub btnRecSetNameFirst_Click()
- rsRecSetName.MoveFirst
- RecSetNamePopulate
- RecSetNameButtonStatus
- Exit Sub
- End Sub
- Private Sub btnRecSetNameNext_Click()
- If Not rsRecSetName.EOF Then
- RecSetNamePopulate
- End If
- RecSetNameButtonStatus
- Exit Sub
- End Sub
- Private Sub btnRecSetNamePrevious_Click()
- If Not rsRecSetName.BOF Then
- rsRecSetName.MovePrevious
- rsRecSetName.MovePrevious
- RecSetNamePopulate
- End If
- RecSetNameButtonStatus
- Exit Sub
- End Sub
- Private Sub Sample_Form_Load()
- '** Here is all initialization required prior to any
- '** Navigation of Recordset.
- Set dbDatabase = DBEngine.Workspaces(0).OpenDatabase("c:\vb\biblio.mdb")
- Set rsRecSetName = dbDatabase.OpenRecordset("select * from [publishers]")
- RecSetNameCreateControls
- Exit Sub
- End Sub
- Private Sub Form_Load()
- End Sub
-